<HTML>
<HEAD>
<META http-equiv="content-type" content="text/html; charset=utf-8" />
<TITLE>RTW Report - Body.c </TITLE>
</HEAD>
<BODY BGCOLOR="#eeeeee" TEXT="#1122aa" ONLOAD="if (top) { if (top.rtwFileOnLoad) top.rtwFileOnLoad(window);}">
<P>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="6" WIDTH="100%" HEIGHT="100%"><TR><TD WIDTH="100%" VALIGN="top" BGCOLOR="#ffffff">
<H4>File: <A HREF="file:///home/ying/Documents/lockheed/codegen/mex/sphere_on_sphere/Body.c" TARGET="rtwreport_document_frame">/home/ying/Documents/lockheed/codegen/mex/sphere_on_sphere/Body.c</A></H4>
<PRE id="RTWcode">
<A NAME="1"><FONT COLOR="#888888"><I>    1   </I></FONT></A><FONT COLOR="#117755"><I>/*</I></FONT>
<A NAME="2"><FONT COLOR="#888888"><I>    2   </I></FONT></A><FONT COLOR="#117755"><I> * Body.c</I></FONT>
<A NAME="3"><FONT COLOR="#888888"><I>    3   </I></FONT></A><FONT COLOR="#117755"><I> *</I></FONT>
<A NAME="4"><FONT COLOR="#888888"><I>    4   </I></FONT></A><FONT COLOR="#117755"><I> * Code generation for function 'Body'</I></FONT>
<A NAME="5"><FONT COLOR="#888888"><I>    5   </I></FONT></A><FONT COLOR="#117755"><I> *</I></FONT>
<A NAME="6"><FONT COLOR="#888888"><I>    6   </I></FONT></A><FONT COLOR="#117755"><I> * C source code generated on: Sat Oct 18 11:56:05 2014</I></FONT>
<A NAME="7"><FONT COLOR="#888888"><I>    7   </I></FONT></A><FONT COLOR="#117755"><I> *</I></FONT>
<A NAME="8"><FONT COLOR="#888888"><I>    8   </I></FONT></A><FONT COLOR="#117755"><I> */</I></FONT>
<A NAME="9"><FONT COLOR="#888888"><I>    9   </I></FONT></A>
<A NAME="10"><FONT COLOR="#888888"><I>   10   </I></FONT></A><FONT COLOR="#117755"><I>/* Include files */</I></FONT>
<A NAME="11"><FONT COLOR="#888888"><I>   11   </I></FONT></A><FONT COLOR="#992211">#</FONT><FONT COLOR="#992211"><B>include</B></FONT> <FONT COLOR="#992211">&quot;rt_nonfinite.h&quot;</FONT>
<A NAME="12"><FONT COLOR="#888888"><I>   12   </I></FONT></A><FONT COLOR="#992211">#</FONT><FONT COLOR="#992211"><B>include</B></FONT> <FONT COLOR="#992211">&quot;sphere_on_sphere.h&quot;</FONT>
<A NAME="13"><FONT COLOR="#888888"><I>   13   </I></FONT></A><FONT COLOR="#992211">#</FONT><FONT COLOR="#992211"><B>include</B></FONT> <FONT COLOR="#992211">&quot;Body.h&quot;</FONT>
<A NAME="14"><FONT COLOR="#888888"><I>   14   </I></FONT></A>
<A NAME="15"><FONT COLOR="#888888"><I>   15   </I></FONT></A><FONT COLOR="#117755"><I>/* Type Definitions */</I></FONT>
<A NAME="16"><FONT COLOR="#888888"><I>   16   </I></FONT></A>
<A NAME="17"><FONT COLOR="#888888"><I>   17   </I></FONT></A><FONT COLOR="#117755"><I>/* Named Constants */</I></FONT>
<A NAME="18"><FONT COLOR="#888888"><I>   18   </I></FONT></A>
<A NAME="19"><FONT COLOR="#888888"><I>   19   </I></FONT></A><FONT COLOR="#117755"><I>/* Variable Declarations */</I></FONT>
<A NAME="20"><FONT COLOR="#888888"><I>   20   </I></FONT></A>
<A NAME="21"><FONT COLOR="#888888"><I>   21   </I></FONT></A><FONT COLOR="#117755"><I>/* Variable Definitions */</I></FONT>
<A NAME="22"><FONT COLOR="#888888"><I>   22   </I></FONT></A>
<A NAME="23"><FONT COLOR="#888888"><I>   23   </I></FONT></A><FONT COLOR="#117755"><I>/* Function Declarations */</I></FONT>
<A NAME="24"><FONT COLOR="#888888"><I>   24   </I></FONT></A>
<A NAME="25"><FONT COLOR="#888888"><I>   25   </I></FONT></A><FONT COLOR="#117755"><I>/* Function Definitions */</I></FONT>
<A NAME="26"><FONT COLOR="#888888"><I>   26   </I></FONT></A>
<A NAME="27"><FONT COLOR="#888888"><I>   27   </I></FONT></A><FONT COLOR="#112266"><B>void</B></FONT> <A NAME="fcn_Body">Body</A>(<A HREF="sphere_on_sphere_types_h.html#type_b_struct_T" ONCLICK="if (top) if (top.docHiliteMe) top.docHiliteMe(window, 'var_b_struct_T');" TARGET="rtwreport_document_frame"><FONT COLOR="#1122aa">b_struct_T</FONT></A> *B)
<A NAME="28"><FONT COLOR="#888888"><I>   28   </I></FONT></A><B>{</B>
<A NAME="29"><FONT COLOR="#888888"><I>   29   </I></FONT></A>    int32_T i;
<A NAME="30"><FONT COLOR="#888888"><I>   30   </I></FONT></A>    <FONT COLOR="#112266"><B>static</B></FONT> <FONT COLOR="#112266"><B>const</B></FONT> char_T cv2[4] = <B>{</B> <FONT COLOR="#1122ff">'b'</FONT>, <FONT COLOR="#1122ff">'o'</FONT>, <FONT COLOR="#1122ff">'d'</FONT>, <FONT COLOR="#1122ff">'y'</FONT> <B>}</B>;
<A NAME="31"><FONT COLOR="#888888"><I>   31   </I></FONT></A>    <FONT COLOR="#112266"><B>static</B></FONT> <FONT COLOR="#112266"><B>const</B></FONT> char_T cv3[7] = <B>{</B> <FONT COLOR="#1122ff">'g'</FONT>, <FONT COLOR="#1122ff">'e'</FONT>, <FONT COLOR="#1122ff">'n'</FONT>, <FONT COLOR="#1122ff">'e'</FONT>, <FONT COLOR="#1122ff">'r'</FONT>, <FONT COLOR="#1122ff">'i'</FONT>, <FONT COLOR="#1122ff">'c'</FONT> <B>}</B>;
<A NAME="32"><FONT COLOR="#888888"><I>   32   </I></FONT></A>    <FONT COLOR="#112266"><B>static</B></FONT> <FONT COLOR="#112266"><B>const</B></FONT> int8_T iv1[4] = <B>{</B> 1, 0, 0, 0 <B>}</B>;
<A NAME="33"><FONT COLOR="#888888"><I>   33   </I></FONT></A>    int8_T I[9];
<A NAME="34"><FONT COLOR="#888888"><I>   34   </I></FONT></A>    <FONT COLOR="#112266"><B>static</B></FONT> <FONT COLOR="#112266"><B>const</B></FONT> int8_T iv2[3] = <B>{</B> 0, 0, 1 <B>}</B>;
<A NAME="35"><FONT COLOR="#888888"><I>   35   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Creates a body struct with default body properties */</I></FONT>
<A NAME="36"><FONT COLOR="#888888"><I>   36   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  The body struct */</I></FONT>
<A NAME="37"><FONT COLOR="#888888"><I>   37   </I></FONT></A>    <FONT COLOR="#117755"><I>/* B = struct; */</I></FONT>
<A NAME="38"><FONT COLOR="#888888"><I>   38   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 4; i++) <B>{</B>
<A NAME="39"><FONT COLOR="#888888"><I>   39   </I></FONT></A>        B-&gt;name[i] = cv2[i];
<A NAME="40"><FONT COLOR="#888888"><I>   40   </I></FONT></A>    <B>}</B>
<A NAME="41"><FONT COLOR="#888888"><I>   41   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 7; i++) <B>{</B>
<A NAME="42"><FONT COLOR="#888888"><I>   42   </I></FONT></A>        B-&gt;type[i] = cv3[i];
<A NAME="43"><FONT COLOR="#888888"><I>   43   </I></FONT></A>    <B>}</B>
<A NAME="44"><FONT COLOR="#888888"><I>   44   </I></FONT></A>    B-&gt;bodyID = 0.0;
<A NAME="45"><FONT COLOR="#888888"><I>   45   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Body's position in the simulation's vector of bodies */</I></FONT>
<A NAME="46"><FONT COLOR="#888888"><I>   46   </I></FONT></A>    B-&gt;bodyContactID = 0.0;
<A NAME="47"><FONT COLOR="#888888"><I>   47   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Body's id for current time-step contact set */</I></FONT>
<A NAME="48"><FONT COLOR="#888888"><I>   48   </I></FONT></A>    B-&gt;bodyDynamicID = 0.0;
<A NAME="49"><FONT COLOR="#888888"><I>   49   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  TODO: duplicate of bodyContactID?  */</I></FONT>
<A NAME="50"><FONT COLOR="#888888"><I>   50   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Physical properties */</I></FONT>
<A NAME="51"><FONT COLOR="#888888"><I>   51   </I></FONT></A>    B-&gt;dynamic = TRUE;
<A NAME="52"><FONT COLOR="#888888"><I>   52   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Dynamic vs. static body  */</I></FONT>
<A NAME="53"><FONT COLOR="#888888"><I>   53   </I></FONT></A>    B-&gt;active = FALSE;
<A NAME="54"><FONT COLOR="#888888"><I>   54   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  An active body is one that is in dynamic interaction with  */</I></FONT>
<A NAME="55"><FONT COLOR="#888888"><I>   55   </I></FONT></A>    <FONT COLOR="#117755"><I>/*    another body through contact or some other constraint.   */</I></FONT>
<A NAME="56"><FONT COLOR="#888888"><I>   56   </I></FONT></A>    B-&gt;mass = 1.0;
<A NAME="57"><FONT COLOR="#888888"><I>   57   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Mass */</I></FONT>
<A NAME="58"><FONT COLOR="#888888"><I>   58   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 3; i++) <B>{</B>
<A NAME="59"><FONT COLOR="#888888"><I>   59   </I></FONT></A>        B-&gt;u[i] = 0.0;
<A NAME="60"><FONT COLOR="#888888"><I>   60   </I></FONT></A>    <B>}</B>
<A NAME="61"><FONT COLOR="#888888"><I>   61   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Position of center of mass */</I></FONT>
<A NAME="62"><FONT COLOR="#888888"><I>   62   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 4; i++) <B>{</B>
<A NAME="63"><FONT COLOR="#888888"><I>   63   </I></FONT></A>        B-&gt;quat[i] = (real_T)iv1[i];
<A NAME="64"><FONT COLOR="#888888"><I>   64   </I></FONT></A>    <B>}</B>
<A NAME="65"><FONT COLOR="#888888"><I>   65   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Quaternion rotation */</I></FONT>
<A NAME="66"><FONT COLOR="#888888"><I>   66   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 9; i++) <B>{</B>
<A NAME="67"><FONT COLOR="#888888"><I>   67   </I></FONT></A>        I[i] = 0;
<A NAME="68"><FONT COLOR="#888888"><I>   68   </I></FONT></A>    <B>}</B>
<A NAME="69"><FONT COLOR="#888888"><I>   69   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 3; i++) <B>{</B>
<A NAME="70"><FONT COLOR="#888888"><I>   70   </I></FONT></A>        I[i + 3 * i] = 1;
<A NAME="71"><FONT COLOR="#888888"><I>   71   </I></FONT></A>    <B>}</B>
<A NAME="72"><FONT COLOR="#888888"><I>   72   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 9; i++) <B>{</B>
<A NAME="73"><FONT COLOR="#888888"><I>   73   </I></FONT></A>        B-&gt;J[i] = (real_T)I[i];
<A NAME="74"><FONT COLOR="#888888"><I>   74   </I></FONT></A>    <B>}</B>
<A NAME="75"><FONT COLOR="#888888"><I>   75   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Inertia tensor */</I></FONT>
<A NAME="76"><FONT COLOR="#888888"><I>   76   </I></FONT></A>    <FONT COLOR="#117755"><I>/* B.v = zeros(3,1);       % Linear velocity */</I></FONT>
<A NAME="77"><FONT COLOR="#888888"><I>   77   </I></FONT></A>    <FONT COLOR="#117755"><I>/* B.w = zeros(3,1);       % Angular velocity */</I></FONT>
<A NAME="78"><FONT COLOR="#888888"><I>   78   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 6; i++) <B>{</B>
<A NAME="79"><FONT COLOR="#888888"><I>   79   </I></FONT></A>        B-&gt;nu[i] = 0.0;
<A NAME="80"><FONT COLOR="#888888"><I>   80   </I></FONT></A>        <FONT COLOR="#117755"><I>/*  Generalized velocity [v; w] */</I></FONT>
<A NAME="81"><FONT COLOR="#888888"><I>   81   </I></FONT></A>        B-&gt;Fext[i] = 0.0;
<A NAME="82"><FONT COLOR="#888888"><I>   82   </I></FONT></A>        <FONT COLOR="#117755"><I>/*  External force */</I></FONT>
<A NAME="83"><FONT COLOR="#888888"><I>   83   </I></FONT></A>        B-&gt;Aext[i] = 0.0;
<A NAME="84"><FONT COLOR="#888888"><I>   84   </I></FONT></A>    <B>}</B>
<A NAME="85"><FONT COLOR="#888888"><I>   85   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  External acceleration */</I></FONT>
<A NAME="86"><FONT COLOR="#888888"><I>   86   </I></FONT></A>    B-&gt;mu = 0.5;
<A NAME="87"><FONT COLOR="#888888"><I>   87   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Friction factor */</I></FONT>
<A NAME="88"><FONT COLOR="#888888"><I>   88   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Joint-related properties */</I></FONT>
<A NAME="89"><FONT COLOR="#888888"><I>   89   </I></FONT></A>    B-&gt;numJoints = 0.0;
<A NAME="90"><FONT COLOR="#888888"><I>   90   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Graphics properties  */</I></FONT>
<A NAME="91"><FONT COLOR="#888888"><I>   91   </I></FONT></A>    B-&gt;visible = TRUE;
<A NAME="92"><FONT COLOR="#888888"><I>   92   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Graphics object for plotting the body */</I></FONT>
<A NAME="93"><FONT COLOR="#888888"><I>   93   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 3; i++) <B>{</B>
<A NAME="94"><FONT COLOR="#888888"><I>   94   </I></FONT></A>        B-&gt;color[i] = (real_T)iv2[i];
<A NAME="95"><FONT COLOR="#888888"><I>   95   </I></FONT></A>    <B>}</B>
<A NAME="96"><FONT COLOR="#888888"><I>   96   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Color of body */</I></FONT>
<A NAME="97"><FONT COLOR="#888888"><I>   97   </I></FONT></A>    B-&gt;facealpha = 0.7;
<A NAME="98"><FONT COLOR="#888888"><I>   98   </I></FONT></A>    B-&gt;edgealpha = 1.0;
<A NAME="99"><FONT COLOR="#888888"><I>   99   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Graphics object for plotting bounding box */</I></FONT>
<A NAME="100"><FONT COLOR="#888888"><I>  100   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Collision detection properties */</I></FONT>
<A NAME="101"><FONT COLOR="#888888"><I>  101   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 3; i++) <B>{</B>
<A NAME="102"><FONT COLOR="#888888"><I>  102   </I></FONT></A>        B-&gt;AABB_min[i] = 0.0;
<A NAME="103"><FONT COLOR="#888888"><I>  103   </I></FONT></A>        <FONT COLOR="#117755"><I>/*  Bounding box */</I></FONT>
<A NAME="104"><FONT COLOR="#888888"><I>  104   </I></FONT></A>        B-&gt;AABB_max[i] = 0.0;
<A NAME="105"><FONT COLOR="#888888"><I>  105   </I></FONT></A>    <B>}</B>
<A NAME="106"><FONT COLOR="#888888"><I>  106   </I></FONT></A>    B-&gt;collides = TRUE;
<A NAME="107"><FONT COLOR="#888888"><I>  107   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  If false, this body won't collide with any other bodies */</I></FONT>
<A NAME="108"><FONT COLOR="#888888"><I>  108   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  A list of bodyIDs of bodies not to do collision detection with */</I></FONT>
<A NAME="109"><FONT COLOR="#888888"><I>  109   </I></FONT></A>    <FONT COLOR="#117755"><I>/*     %% Different bodies have different attributes, but for simplicity  */</I></FONT>
<A NAME="110"><FONT COLOR="#888888"><I>  110   </I></FONT></A>    <FONT COLOR="#117755"><I>/*   we want all bodies to be represented by this struct.  Therefore we */</I></FONT>
<A NAME="111"><FONT COLOR="#888888"><I>  111   </I></FONT></A>    <FONT COLOR="#117755"><I>/*   place all body attributes here, and let bodies pick and choose. */</I></FONT>
<A NAME="112"><FONT COLOR="#888888"><I>  112   </I></FONT></A>    <FONT COLOR="#117755"><I>/*     %% Sphere attributes */</I></FONT>
<A NAME="113"><FONT COLOR="#888888"><I>  113   </I></FONT></A>    B-&gt;radius = 1.0;
<A NAME="114"><FONT COLOR="#888888"><I>  114   </I></FONT></A>    B-&gt;num_sphere_verts = 7.0;
<A NAME="115"><FONT COLOR="#888888"><I>  115   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  Decrease to improve graphics performance  */</I></FONT>
<A NAME="116"><FONT COLOR="#888888"><I>  116   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  (does not affect simulation result) */</I></FONT>
<A NAME="117"><FONT COLOR="#888888"><I>  117   </I></FONT></A>    <FONT COLOR="#117755"><I>/*     %% Cylinder attributes */</I></FONT>
<A NAME="118"><FONT COLOR="#888888"><I>  118   </I></FONT></A>    B-&gt;height = 1.0;
<A NAME="119"><FONT COLOR="#888888"><I>  119   </I></FONT></A>    <FONT COLOR="#117755"><I>/*     %% Plane attributes */</I></FONT>
<A NAME="120"><FONT COLOR="#888888"><I>  120   </I></FONT></A>    <FONT COLOR="#112266"><B>for</B></FONT> (i = 0; i &lt; 3; i++) <B>{</B>
<A NAME="121"><FONT COLOR="#888888"><I>  121   </I></FONT></A>        B-&gt;plane_normal[i] = (real_T)iv2[i];
<A NAME="122"><FONT COLOR="#888888"><I>  122   </I></FONT></A>    <B>}</B>
<A NAME="123"><FONT COLOR="#888888"><I>  123   </I></FONT></A>    <FONT COLOR="#117755"><I>/*     %% Mesh attributes */</I></FONT>
<A NAME="124"><FONT COLOR="#888888"><I>  124   </I></FONT></A>    B-&gt;num_verts = 0.0;
<A NAME="125"><FONT COLOR="#888888"><I>  125   </I></FONT></A>    B-&gt;num_edges = 0.0;
<A NAME="126"><FONT COLOR="#888888"><I>  126   </I></FONT></A>    B-&gt;num_faces = 0.0;
<A NAME="127"><FONT COLOR="#888888"><I>  127   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  A Nx3 vector of N vertices relative to the COM of the body */</I></FONT>
<A NAME="128"><FONT COLOR="#888888"><I>  128   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  A Nx3 vector of N vertices in the world space */</I></FONT>
<A NAME="129"><FONT COLOR="#888888"><I>  129   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  A Ex [v1 v2 Enext Eopp face]   TODO: remove implicit columns Enext and face */</I></FONT>
<A NAME="130"><FONT COLOR="#888888"><I>  130   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  A Ex5 vector [v1 v2 f1 f2 a] where v1:first */</I></FONT>
<A NAME="131"><FONT COLOR="#888888"><I>  131   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  vert, v2: second vert, f1: first face, f2: */</I></FONT>
<A NAME="132"><FONT COLOR="#888888"><I>  132   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  second face, a: angle between faces */</I></FONT>
<A NAME="133"><FONT COLOR="#888888"><I>  133   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  A Ex6 vector of t vectors (always in local coords), perp to edge and planar to adjacent faces */</I></FONT>
<A NAME="134"><FONT COLOR="#888888"><I>  134   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  A Mx4 vector of M faces where each row contains: [v1 v2 v3 e1] */</I></FONT>
<A NAME="135"><FONT COLOR="#888888"><I>  135   </I></FONT></A>    <FONT COLOR="#117755"><I>/*  A Mx3 vector of M face norms where each row contains [n1 n2 n3]  */</I></FONT>
<A NAME="136"><FONT COLOR="#888888"><I>  136   </I></FONT></A><B>}</B>
<A NAME="137"><FONT COLOR="#888888"><I>  137   </I></FONT></A><FONT COLOR="#117755"><I>/* End of code generation (Body.c) */</I></FONT>
<A NAME="138"><FONT COLOR="#888888"><I>  138   </I></FONT></A></PRE>
</TD></TR></TABLE>
</P>
</BODY>
</HTML>